package com.csx.framework.springboot.sample.ioc;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p> what does this class do ? </p>
 * <p> How does it work ?</p>
 * <p> Why does it do this ?</p>
 *
 * @author cuisongxu
 * @date 2024/12/17 周二 10:12
 */
@Component
public class A {

    private B b;

    private C c;

    private D d;

    @Autowired
    public void setB(B b) {
        this.b = b;
        System.out.println("setter 注入B");
    }

    @Autowired
    public void setC(C c) {
        this.c = c;
    }

    @Autowired
    public void okD(D d) {
        this.d = d;
    }

//    @Autowired
//    public A(D d) {
//        this.d = d;
//        System.out.println("有参数构造器");
//    }

    public A() {
        System.out.println("无参数构造器");
    }

    @PostConstruct
    public void init() {
        System.out.println("A 的 @PostConstruct 标注的方法在初始化之前执行，后于 postProcessBeforeInitialization 执行");
        System.out.println();
    }

    @Override
    public String toString() {
        return "A{" +
                "b=" + b +
                ", c=" + c +
                ", d=" + d +
                '}';
    }
}
